using System;
using System.IO;
using System.Windows.Media;
using Intuipic.Interop;

namespace Intuipic.Data
{
	/// <summary>
	/// Provides a concrete implementation of <see cref="InformationBase"/> that represents the user's My Computer location.
	/// </summary>
	/// <remarks>
	/// This class implements the singleton pattern to ensure that only one instance of <c>MyComputerInformation</c> exists.
	/// </remarks>
	public sealed class MyComputerInformation : InformationBase
	{
		private static readonly ImageSource _icon = IconHelper.GetSpecialFolderIcon(Environment.SpecialFolder.MyComputer);
		private static readonly MyComputerInformation _instance = new MyComputerInformation();

		/// <summary>
		/// Gets the one and only instance of <see cref="MyComputerInformation"/>.
		/// </summary>
		public static MyComputerInformation Instance
		{
			get
			{
				return _instance;
			}
		}

		private MyComputerInformation()
			: base("My Computer", null, _icon, _icon, null)
		{
		}

		/// <summary>
		/// Loads the children of this My Computer informational item.
		/// </summary>
		protected override void LoadChildrenCore()
		{
			foreach (DriveInfo driveInfo in DriveInfo.GetDrives())
			{
				Children.Add(DriveInformation.GetDriveInformation(driveInfo));
			}
		}
	}
}
